//
//  SLBottomCameraAlbumButton.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/22.
//

#import "SLBottomCameraAlbumButton.h"
#import <YYKit.h>
#import <Masonry.h>
#import <YYKit.h>

@interface SLBottomCameraAlbumButton ()
@property (nonatomic, strong) UIStackView *stackView;
@end
@implementation SLBottomCameraAlbumButton


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = UIColorHex(#FDC5E0);
        [self addSubview:self.stackView];
        [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self).inset(35);
            make.top.equalTo(self).offset(11);
            make.height.mas_equalTo(54);
        }];
        
        [self.stackView addArrangedSubview:self.albumButton];
        [self.stackView addArrangedSubview:self.cameraButton];
    }
    return self;
}

- (void)albumButtonAction:(UIButton *)button {
    !self.albumButtonCallback ?: self.albumButtonCallback();
}

- (void)cameraButtonAction:(UIButton *)button {
    !self.cameraButtonCallback ?: self.cameraButtonCallback();
}



- (UIStackView *)stackView {
    if (!_stackView) {
        _stackView = [UIStackView new];
        _stackView.distribution = UIStackViewDistributionFillEqually;
        _stackView.spacing = 23;
    }
    return _stackView;
}


- (UIButton *)albumButton {
    if (!_albumButton) {
        _albumButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_albumButton setTitle:@"Photo Album" forState:UIControlStateNormal];
        [_albumButton setTitleColor:UIColorHex(#1B1B1B) forState:UIControlStateNormal];
        _albumButton.titleLabel.font = aspectDefaultFont(16);
        _albumButton.backgroundColor = UIColor.whiteColor;
        _albumButton.layer.cornerRadius = 20;
        _albumButton.layer.borderColor = UIColorHex(#1B1B1B).CGColor;
        _albumButton.layer.borderWidth = 1;
        [_albumButton addTarget:self action:@selector(albumButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _albumButton;
}

- (UIButton *)cameraButton {
    if (!_cameraButton) {
        _cameraButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cameraButton setTitle:@"Photograph" forState:UIControlStateNormal];
        [_cameraButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
        _cameraButton.titleLabel.font = aspectDefaultFont(16);
        _cameraButton.backgroundColor = UIColorHex(#1B1B1B);
        _cameraButton.layer.cornerRadius = 20;
        _cameraButton.layer.borderColor = UIColorHex(#1B1B1B).CGColor;
        _cameraButton.layer.borderWidth = 1;
        [_cameraButton addTarget:self action:@selector(cameraButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cameraButton;
}
@end
